import Cookies from 'js-cookie'
import store from "@/store";

const TokenKey = 'Agent-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

/**
 * 打开美客多授权页面
 */
export function mkdAuth(){
  // const state = store.getters.authState;
  // const clientId = process.env.VUE_APP_MKD_CLENT_ID;
  // const redirectUrl = `https://auth.mercadolibre.com.mx/authorization?response_type=code&client_id=${clientId}&state=${state}&redirect_uri=https%3A%2F%2Fmercado-api.melidropship.com%2Fredirect`
  const redirectUrl = store.getters.authUrl;
  window.open(redirectUrl ,'_blank')
}

export function mkdCBTAuth(){
  const redirectUrl = store.getters.cbtAuthUrl;
  window.open(redirectUrl ,'_blank')
}
